<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>企业空间</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="bootstrap-3.3.7-dist/css/bootstrap.css" rel="stylesheet">
<script src="bootstrap-3.3.7-dist/js/bootstrap-datetimepicker.css"></script>
<script src="style/js/jquery-1.11.1.js"></script>
<script src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script src="bootstrap-3.3.7-dist/js/bootstrap-datetimepicker.js"></script>
<script src="bootstrap-3.3.7-dist/js/locales/bootstrap-datetimepicker.fr.js"></script>

<link rel="stylesheet" href="calendar/css/calendar.css">
<script src="calendar/js/calendar.js"></script>

<style type="text/css">
#toprow {
	
}

#topcolumn {
	padding: 0px;
}

.container {
	margin: 0px;
	width: 100%;
	height:100%;
}

.leftbutton {
	margin: 0px;	
	padding-top:10px;
	padding-bottom:50px;
	padding-left:20px;
	cursor: pointer;
}

.leftbutton:hover {
	background-color: #46A3FF	
}

.buttoncss {
	float: left;
	
	/* margin-top:10px;
	margin-bottom:10px;
	margin-left:20px; */
}

.buttoncss:hover {
	background-color: #46A3FF
}

.buttonword{
	margin-left:10px;
	margin-top:8px;
 	height:40px;
	color:#FFFFFF;
	float: right;
}

/* 动态的css */
.dynamics{
border-bottom:1px solid #d0d0d0;
}

.dynamics-head{
float:left;width:10%;height:100%
}


.dynamics-head-img{
padding-top:30%;height:90%;width:90%;
}

.dynamics-username{
float:left;width:90%;height:100%;
}

.dynamics-content{
border-bottom:1px solid #d0d0d0;
}

</style>
<script type="text/javascript">
$(function(){
		
		
	//$("#notice").function(){
		$.post("notice.do",
				{
				},function(data){
					$("#noticecontent").html(data.description);
				},"json" 
		); 
		
		//获取公司全部动态
		$.post("getAllShares.do",
				{
				},function(data){
					html="";
					for (var i = 0; i < data.length; i++){
						html+="<div class='dynamics'><div class='dynamics-head'><img class='dynamics-head-img' src='"+
						data[i].head+"'></div><div class='dynamics-username'><h1 class='dynamics-content'>"+data[i].username+
						"</h1><p>"+data[i].content+"</div>&nbsp;</div>"
					}
					$("#panel-shares").empty();
					$("#panel-shares").append(html);
				},"json" 
		); 
		
		//获取公司的个人动态
		$.post("usergetAllShares.do",
				{
				},function(data){
					html="";
					for (var i = 0; i < data.length; i++){
						html+="<div class='dynamics'><div class='dynamics-head'><img class='dynamics-head-img' src='"+
						data[i].head+"'></div><div class='dynamics-username'><h1 class='dynamics-content'>"+data[i].username+
						"</h1><p>"+data[i].content+"</div>&nbsp;</div>"
					}
					$("#panel-sharesofmine").empty();
					$("#panel-sharesofmine").append(html);
				},"json" 
		); 
		
	//}
//-------------------初始加载事件↑--------------------------表单↓---------------------------------------------------
	//提交公告的按钮事件
	$("#noticesubmit").click(function(){
		$.post("releasenotice.do",
				{
					description:$('#noticedescription').val(),
				},function(data){
					//alert(data);
					if(data){
						alert("发布成功!");
						
						$.post("notice.do",
								{
								},function(data){
									$("#noticecontent").html(data.description);
								},"json" 
						); 
						
					}else{
						alert("发布失败!");
					}
				},"json" 
		); 
	});
	
	//提交分享的按钮事件
	$("#sharesubmit").click(function(){
		$.post("usershare.do",
				{
					content:$('#sharecontent').val(),
				},function(data){
					//alert(data);
					if(data){
						alert("分享成功");
						
						$.post("getAllShares.do",
								{
								},function(data){
									html="";
									for (var i = 0; i < data.length; i++){
										html+="<div class='dynamics'><div class='dynamics-head'><img class='dynamics-head-img' src='"+
										data[i].head+"'></div><div class='dynamics-username'><h1 class='dynamics-content'>"+data[i].username+
										"</h1><p>"+data[i].content+"</div>&nbsp;</div>"
									}
									$("#panel-shares").empty();
									$("#panel-shares").append(html);
								},"json" 
						); 
						
					}else{
						alert("分享失败");
					}
				},"json" 
		); 
	});
	
	//载入负责人的按钮事件
	$("#choseleader").click(function(){
		$.post("getallusers.do",
				{
				},function(data){
					html="";
					for (var i = 0; i < data.length; i++){
						html+="<input name='leader' type='radio' value="+data[i].userid+" checked='checked' />"+data[i].username
					}
					$("#choseleaderdiv").empty();
					$("#choseleaderdiv").append(html);
				},"json" 
			);
	});
	
	//载入任务参与者的按钮事件
	$("#chosemember").click(function(){
		$.post("getallusers.do",
				{
				},function(data){
					html="";
					for (var i = 0; i < data.length; i++){
						html+="<input name='member' type='checkbox' value="+data[i].userid+" />"+data[i].username
					}
					$("#chosememberdiv").empty();
					$("#chosememberdiv").append(html);
				},"json" 
			);
	});
	
	//提交任务的按钮事件
	$("#missionsubmit").click(function(){
			  var param="missionname="+$('#missionname').val()+"&missiondescription="+$('#missiondescription').val()+"&leaderid=";
			  param+=$("#choseleaderdiv input:radio[name='leader']:checked").val();
			  param+="&memberid=";
			  $("#chosememberdiv input:checkbox[name='member']:checked").each(function(){
			   param+=$(this).val()+",";
			  });
			  param+="&starttime="+$("input[name='missionstarttime']").val();
			  param+="&endtime="+$("input[name='missionendtime']").val(); 
		$.ajax({
			type : 'post',
			url : 'addmission.do',
			data : param,
			success : function(data) {
				alert("发布任务成功！");
				$.post("getAllShares.do",
						{
						},function(data){
							html="";
							for (var i = 0; i < data.length; i++){
								html+="<div class='dynamics'><div class='dynamics-head'><img class='dynamics-head-img' src='"+
								data[i].head+"'></div><div class='dynamics-username'><h1 class='dynamics-content'>"+data[i].username+
								"</h1><p>"+data[i].content+"</div>&nbsp;</div>"
							}
							$("#panel-shares").empty();
							$("#panel-shares").append(html);
						},"json" 
				); 
			},
			error : function() {
				alert("出错了！");
			}
		}); 
	});
	
//---------------任务↑---------------------------活动↓-------------------------------------	
	
	//载入活动参与者的按钮事件
	$("#choseactivitymember").click(function(){
		$.post("getallusers.do",
				{
				},function(data){
					html="";
					for (var i = 0; i < data.length; i++){
						html+="<input name='activitymember' type='checkbox' value="+data[i].userid+" />"+data[i].username
					}
					$("#choseactivitymemberdiv").empty();
					$("#choseactivitymemberdiv").append(html);
				},"json" 
			);
	});
	
	//提交活动的按钮事件
	$("#activitysubmit").click(function(){
			  var param="activityname="+$('#activityname').val()+"&activitydescription="+$('#activitydescription').val();
			  param+="&activityaddress="+$('#activityaddress').val();
			  param+="&activitymemberid=";
			  $("#choseactivitymemberdiv input:checkbox[name='activitymember']:checked").each(function(){
			   param+=$(this).val()+",";
			  });
			  param+="&starttime="+$("input[name='activitystarttime']").val();
			  param+="&endtime="+$("input[name='activityendtime']").val(); 
			  alert(param);
		$.ajax({
			type : 'post',
			url : 'addactivity.do',
			data : param,
			success : function(data) {
				alert("发布活动成功！");
				$.post("getAllShares.do",
						{
						},function(data){
							html="";
							for (var i = 0; i < data.length; i++){
								html+="<div class='dynamics'><div class='dynamics-head'><img class='dynamics-head-img' src='"+
								data[i].head+"'></div><div class='dynamics-username'><h1 class='dynamics-content'>"+data[i].username+
								"</h1><p>"+data[i].content+"</div>&nbsp;</div>"
							}
							$("#panel-shares").empty();
							$("#panel-shares").append(html);
						},"json" 
				); 
			},
			error : function() {
				alert("出错了！");
			}
		}); 
	});
	
	
	
	$('.teamtimepicker').datetimepicker({
	});
	
	//----------------------发布表单↑----------------------动态↓-------------------------------------------------
	/* $("#reply-toggle-1").click(function(){
		  $("#reply-1").toggle(500);
	}); */
});



</script>

</head>
<body>
	<div class="container">
		<!-- 顶部导航栏 -->
		<div id="toprow" class="row clearfix">
			<div id="topcolumn" class="col-md-12 column">
				<nav style="margin: 0px" class="navbar navbar-default"
					role="navigation">
					<div class="navbar-header">
						<img style="width: 75px; height: 40px"
							src="style/image/ateamlogo.png">
						<!-- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button> <a class="navbar-brand" href="#">Brand</a> -->
					</div>

					<div class="collapse navbar-collapse"
						id="bs-example-navbar-collapse-1">
						<ul class="nav navbar-nav">
							<li><h4>${currentCompany.companyname}</h4></li>
						</ul>

						<ul class="nav navbar-nav navbar-right">
							<li>
								<form class="navbar-form navbar-left" role="search">
									<div class="form-group">
										<input type="text" class="form-control" />
									</div>
									<button type="submit" class="btn btn-default">Submit</button>
								</form>
							</li>
							<li>
								<c:if test="${currentUser.role == 1}">
							<button onclick="javascript:location.href='getapplyers.do'" class="btn btn-small" type="button">申请</button>
							 	</c:if>
							 	<c:if test="${currentUser.role == 2}">
							<button onclick="javascript:location.href='getapplyers.do'" style="display:none;" class="btn btn-small disabled" type="button">申请</button>
							 	</c:if>
							</li>
							<li>
							<button onclick="javascript:location.href='logout.do'" class="btn btn-success" type="button">注销</button>
							</li>
						</ul>
					</div>

				</nav>
			</div>
		</div>

		<!-- 主体 -->
		<div class="row clearfix">
			<!-- 左边的按钮列表 -->
			<div style="padding: 0px; margin-bottom:0px;background-color: #84C1FF"
				class="col-md-1 column">
				<div onclick="javascript:location.href='userinfo.jsp'" style="padding:5px;height:180px" class="leftbutton"><div><img style="height:100px;width:100px;cursor: pointer;" src="${currentUser.head}"><h1>${currentUser.username}</h1></div></div>
				<div style="background-color: #46A3FF" class="leftbutton"><div class="buttoncss"><img src="style/image/ico/动态.png"><div class="buttonword">动态</div></div></div>
				<div class="leftbutton" onclick="javascript:location.href='backlog.jsp'"><div class="buttoncss"><img src="style/image/ico/待办.png"><div class="buttonword">待办</div></div></div>
				<div class="leftbutton" onclick="javascript:location.href='project.jsp'"><div class="buttoncss"><img src="style/image/ico/项目.png"><div class="buttonword">项目</div></div></div>
				<div class="leftbutton" onclick="javascript:location.href='group.jsp'"><div class="buttoncss"><img src="style/image/ico/小组.png"><div class="buttonword">小组</div></div></div>
				<div class="leftbutton" onclick="javascript:location.href='getcolleagues.do'"><div class="buttoncss"><img src="style/image/ico/同事.png"><div class="buttonword">同事</div></div></div>
				<div class="leftbutton" onclick="javascript:location.href='approval.jsp'"><div class="buttoncss"><img src="style/image/ico/审批.png"><div class="buttonword">审批</div></div></div>
				<div class="leftbutton" onclick="javascript:location.href='gotochart.do'"><div class="buttoncss"><img src="style/image/ico/报表.png"><div class="buttonword">报表</div></div></div>
			</div>

			<!-- 右边的内容  这里修改了bootstrap.css中关于滚动条的长度-->
			<div class="col-md-11 column pre-scrollable">
				<!-- 动态的左边 -->
				<div
					style="width: 70%; display: block; float: left;padding-right:10px">
					<div class="tabbable" id="tabs-666529">
						<ul class="nav nav-tabs">
							<li class="active"><a href="#panel-share" data-toggle="tab">发分享</a></li>
							<li><a href="#panel-mission" data-toggle="tab">发任务</a></li>
							<li><a href="#panel-activity" data-toggle="tab">发活动</a></li>
						</ul>
						<div class="tab-content">
						
							<!-- 发起分享的表单 -->
							<div class="tab-pane active" id="panel-share">
								<form id="shareform" method="get" role="form">
									<div class="form-group">
										<textarea
										placeholder="请输入分享内容" rows="3" class="form-control" name="content" id="sharecontent" ></textarea>
									</div>
									<button style="float:right" id="sharesubmit" type="button" class="btn btn-default">分享</button>
								</form>
							</div>
							
							<!-- 发起任务的表单 -->
							<div class="tab-pane" id="panel-mission">
								
									<div class="form-group">
										<input
										placeholder="请输入任务名称"	type="text" class="form-control" id="missionname" />
									</div>
									<div class="form-group">
										<button  class="btn" id="choseleader" type="button">选择负责人</button>
										<div id="choseleaderdiv"></div>
									</div>
									<div class="form-group">
										<a style="float:left">开始时间</a>
										<div style="float:left" class="input-append date teamtimepicker" id="datetimepicker" data-date="2017-08-04 01:00:00" data-date-format="yyyy-mm-dd hh:ii:ss">
    										<input name="missionstarttime" size="16" type="text" value="2017-08-04 01:00:00" >
    										<span class="add-on"><i class="icon-th"></i></span>
										</div> 
										&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										<a style="float:left">结束时间</a>	
										<div style="float:left"  class="input-append date teamtimepicker"  data-date="2017-08-04 01:00:00" data-date-format="yyyy-mm-dd hh:ii:ss">
    										<input name="missionendtime" size="16" type="text" value="2017-08-04 01:00:00" >
    										<span class="add-on"><i class="icon-th"></i></span>
										</div> 
									</div>
									<br />
									<div class="form-group">
										<button  class="btn" id="chosemember" type="button">选择参与者</button>
										<div id="chosememberdiv"></div>
									</div>
									<div class="form-group">
											<textarea
											placeholder="请输入任务描述" rows="3" class="form-control" name="content" id="missiondescription" ></textarea>
									</div>
									  
									<button style="float:right" id="missionsubmit" type="submit" class="btn btn-default">发布</button>
							</div>
							
<!------------------------------------------ 发起活动的表单--------------------------------------------------------->
							<div class="tab-pane" id="panel-activity">
								<div class="form-group">
										<input
										placeholder="请输入活动名称"	type="text" class="form-control" id="activityname" />
									</div>
									<div class="form-group">
										<button class="btn" id="choseactivitymember" type="button">选择参与者</button>
										<div id="choseactivitymemberdiv"></div>
									</div>
									<div class="form-group">
										<a style="float:left">开始时间</a>
										<div style="float:left" class="input-append date teamtimepicker" id="datetimepicker" data-date="2017-08-04 01:00:00" data-date-format="yyyy-mm-dd hh:ii:ss">
    										<input name="activitystarttime" size="16" type="text" value="2017-08-04 01:00:00" >
    										<span class="add-on"><i class="icon-th"></i></span>
										</div> 
										<a style="float:left">结束时间</a>
										<div style="float:left" class="input-append date teamtimepicker"  data-date="2017-08-04 01:00:00" data-date-format="yyyy-mm-dd hh:ii:ss">
    										<input name="activityendtime" size="16" type="text" value="2017-08-04 01:00:00" >
    										<span class="add-on"><i class="icon-th"></i></span>
										</div> 
									</div>
									<div class="form-group">
										<input placeholder="请输入活动地点" type="text"
											class="form-control"
											id="activityaddress" />
									</div>
									<div class="form-group">
											<textarea
											placeholder="请输入活动描述" rows="3" class="form-control" name="content" id="activitydescription" ></textarea>
									</div>					  
									<button style="float:right" id="activitysubmit" type="submit" class="btn btn-default">发布</button>
							</div>
						</div>
					</div>
					
					<div class="tabbable" id="tabs-773216">
						<ul class="nav nav-tabs">
							<li class="active">
								 <a href="#panel-shares" data-toggle="tab">公司动态</a>
							</li>
							<li>
								 <a href="#panel-sharesofmine" data-toggle="tab">我的动态</a>
							</li>
						</ul>
						<div class="tab-content">
							<div class="tab-pane active" id="panel-shares">
								<!-- <div class="dynamics">
									<div class="dynamics-head"><img class="dynamics-head-img" src="style/image/head/profileico1.jpg">
									</div>
									<div class="dynamics-username">
									<h1 class="dynamics-content">sss</h1>
									<p>ssssdf阿萨德发生的发生大范围确认短信发送打法岁的父亲为人妻为人妻为人妻为人妻为人妻为人妻为人妻为人完全而且我妻为人妻为热钱为人完全而未确认为亲人
									<button style="float:right" id="reply-toggle-1" class="btn btn-small btn-link" type="button">回复</button>
									<div id="reply-1"  style="display:none;" class="form-group">
										<textarea
										placeholder="请输入分享内容" rows="3" class="form-control" name="content" ></textarea>
										 <button style="float:right" id="" class="btn btn-mini btn-info" type="button">确认回复</button>
									</div>
									</div>
									&nbsp;
								</div> -->
							</div>
							<div class="tab-pane" id="panel-sharesofmine">
								%nbsp;
							</div>
						</div>
					</div>
					
				</div>

				<!-- 动态的右边 -->
				<div style="width: 30%; display: block; float: left">
					<div id="notice" style="border:1px solid #d0d0d0;border-radius:5px">
						<p>
							<h4 >公告</h4>
							<hr align=center color=#84C1FF size=2>							
							<h5 id="noticecontent"></h5>
					
					<c:if test="${currentUser.role == 1}">
						<div class="form-group">
							<textarea
										placeholder="请输入新公告内容" rows="2" class="form-control" name="noticedescription" id="noticedescription" ></textarea>
									</div>
						<button style="margin-right:3px;" id="noticesubmit" type="button" class="btn btn-default">发布公告</button>
					</c:if>
					<c:if test="${currentUser.role == 2}"></c:if>
					</div>
					<!-- 动态的日历面板 -->
					<div id="calendar" class="calendar"></div>
				</div>
				
				
			</div>
		</div>
	</div>
</body>
</html>